package com.techsoft.session;

import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.techsoft.Session;

public class LocalSession implements Session, Serializable {
	private static final long serialVersionUID = -4029882492086444833L;

	private Long loginTime;
	private Long lastAccessTime;
	private String clientSessionID;
	private String authToken;
	private Map<String, Object> userInfo = new ConcurrentHashMap<String, Object>();

	public LocalSession() {
		loginTime = System.currentTimeMillis();
		lastAccessTime = System.currentTimeMillis();
		authToken = java.util.UUID.randomUUID().toString().replace("-", "");
	}

	@Override
	public Long getLoginTime() {
		return loginTime;
	}

	@Override
	public Long getLastAccessTime() {
		return lastAccessTime;
	}

	@Override
	public void setLastAccessTime(Long time) {
		this.lastAccessTime = time;
	}

	@Override
	public Map<String, Object> getUserInfo() {
		return userInfo;
	}

	@Override
	public void setUserInfo(Map<String, Object> userInfo) {
		this.userInfo.clear();
		this.userInfo.putAll(userInfo);
	}

	@Override
	public String getClientSessionID() {
		return this.clientSessionID;
	}

	@Override
	public void setClientSessionID(String clientSessionID) {
		this.clientSessionID = clientSessionID;

	}

	@Override
	public String getAuthToken() {
		return this.authToken;
	}
}
